setToken()
new Vue({
    el:'#app',
    data:{
        allOrder:[],
        allUnder:[],
        pageIndex:1
    },
    mounted:function(){
      this.$nextTick(function () {
          this.onlineOrder();
          this.underOrder(1);
      })
    },
    methods:{
        //线上订单
        onlineOrder:function () {
            this.$http.get(SURL+'app/orders/allOrder',{params:{pageIndex:1}}).then(function (res) {
                console.log(res)
                if(res.body.status==1){
                    this.allOrder=res.body.data;

                }
            })
        },
        /*
        * @ 线上待支付订单
        *
        * */
        waitPayOrder:function(){
            this.$http.get(SURL+'app/orders/pendingPayment',{params:{pageIndex:1}}).then(function (res) {
               // console.log(res)
                if(res.body.status==1){
                    this.allOrder=res.body.data;
                }
            })
        },
        /*
        * @ 待收货订单
        * */
        takeDelivery:function(){
            this.$http.get(SURL+'app/orders/receiptOfGoods',{params:{pageIndex:this.pageIndex}}).then(function (res) {
               // console.log(res)
                if(res.body.status==1){
                    this.allOrder=res.body.data;
                }
            })
        },
        /*
        * @{
            @"code": "orders-confirmReceipt",
            @"data": {
               @ "orderId":"1" 订单Id
            @}}
        * */
        sureOrder:function(item){
            this.$http.get(SURL+'app/orders/confirmReceipt',{params:{orderId:item.orderId}}).then(function (res) {
                if(res.body.status==1){
                    showDefault('success','操作成功')
                }else{
                    showDefault('fail','操作失败')
                }
            })
        },

        /*
        * @ 已取消的订单
        * */
        canceledOrder:function(){
            this.$http.get(SURL+'')
        },
        /*
        * @ 代发货的订单
        * */
        sendOrder:function(){
          this.$http.get(SURL+'app/orders/toBeShipped',{params:{pageIndex:this.pageIndex}}).then(function (res) {
              if(res.body.status==1){
                  this.allOrder=res.body.data;
              }
          })
        },
        /*
        * @待评价订单
        * */

        evaluateOrder:function(){

                this.$http.get(SURL+'app/orders/toBeEvaluated',{params:{pageIndex:this.pageIndex}}).then(function (res) {
                    if(res.body.status==1){
                        this.allOrder=res.body.data;

                    }
                })

        },
        /*
        *待退款订单
        * */
        refundOrder:function(){
            this.$http.get(SURL+'app/orders/refundOrder',{params:{pageIndex:this.pageIndex}}).then(function (res) {
                if(res.body.status==1){
                    this.allOrder=res.body.data;
                }
            })
        },
        /*
        *   @ 线下商城获取所有的订单
        *   @ page	是	int	页数
            @ pageSize	否	int	每页数量
            @ orderStatus	否	int	订单状态（1：待确认；2：取消；3：已完成）
        * */
        underOrder:function (status) {
            var _this=this;
            _this.$http.get(SURL+'app/orders/orderUser',{params:{page:1,pageSize:10,orderStatus:status}}).then(function (res) {
                console.log(res)
                if(res.body.status==1){
                    this.takeDelivery()
                    _this.allUnder=res.body.data;
                    _this.allUnder.forEach(function (v,i) {
                        _this.$set(v,'status',status)
                    })
                }
            })
        }
    }
})